Skip to content

Fix #305740: avoid sync subprocess wait in TS node path resolution - #305752

Closed
rupeshkumar-555 wants to merge 13 commits into
microsoft:mainfrom
rupeshkumar-555:fix/305740-host-subprocess-timeout
Closed

Fix #305740: avoid sync subprocess wait in TS node path resolution#305752
rupeshkumar-555 wants to merge 13 commits into
microsoft:mainfrom
rupeshkumar-555:fix/305740-host-subprocess-timeout

Conversation

@rupeshkumar-555

Copy link
Copy Markdown

Problem

Issue #305740 reports host unresponsiveness when a subprocess wait blocks an event-loop owned path.

In TypeScript extension configuration, resolving the user-configured node path used a synchronous subprocess call:

  • execFileSync('node', ...)

Even with a timeout, this can still block the extension host event loop during stalls and degrade responsiveness.

Fix

Replaced synchronous subprocess probing with direct PATH-based executable resolution:

  • Added resolveNodeExecutableFromPath helper
  • Removed execFileSync usage from node path detection
  • Retained existing warning behavior when no node executable can be found

This keeps node path resolution fully non-blocking from the event-loop perspective.

Tests

  • Added unit tests for PATH resolution behavior on win32 and non-win32
  • Ran workspace compile successfully (0 errors)
  • Ran focused node tests successfully

Fixes #305740

Copilot AI review requested due to automatic review settings March 27, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses host responsiveness issues in the TypeScript extension by removing synchronous subprocess probing (execFileSync) from Node path detection and replacing it with PATH-based executable resolution.

Changes:

  • Added resolveNodeExecutableFromPath to resolve node via PATH/PATHEXT instead of running a subprocess.
  • Updated findNodePath to use the new resolver and keep the existing warning behavior when Node cannot be detected.
  • Added unit tests covering PATH resolution on win32 and non-win32.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
extensions/typescript-language-features/src/configuration/configuration.electron.ts Replaces sync subprocess detection with PATH-based resolution helper used by Node path detection.
extensions/typescript-language-features/src/test/unit/configuration.electron.test.ts Adds unit coverage for the new PATH-based Node resolution behavior.

@rupeshkumar-555

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@rupeshkumar-555
rupeshkumar-555 force-pushed the fix/305740-host-subprocess-timeout branch from 9ef3f05 to 22ff881 Compare March 28, 2026 04:34
@rupeshkumar-555

Copy link
Copy Markdown
Author

Addressed the remaining Copilot review issue in PR #305752:

  • Updated defaultIsExecutableFile in configuration.electron.ts to use a single lstatSync call in ry/catch instead of existsSync + lstatSync, reducing synchronous fs calls in the success path.

Validation run:

pm run test-node -- --grep typescript.configuration.electron ✅

Notes on environment:

  • Full
    pm run compile is currently blocked in this local Windows environment by dependency/toolchain issues (native build + missing build dependency in this older worktree setup), but the PR-scoped test suite above completes successfully.

@rupeshkumar-555

Copy link
Copy Markdown
Author

Re-verified this PR after syncing latest branch changes.

What is now confirmed:

  • Synchronous subprocess probing is removed from node path detection in TS config.
  • PATH-based resolver is in place with platform-aware path handling (win32/posix split).
  • defaultIsExecutableFile uses a single lstatSync call (no existsSync+lstatSync pair).
  • Unit coverage for win32 and non-win32 resolver behavior is present.

Current PR gate status:

  • Dependencies Check: SUCCESS
  • license/cla: SUCCESS
  • Community PR Approvals: IN_PROGRESS
  • reviewDecision: REVIEW_REQUIRED

No failing CI checks remain from this fix.
Requesting maintainer approval/merge to close #305740.

@rupeshkumar-555

Copy link
Copy Markdown
Author

TylerLeonhardt Ready for review/merge.\n\nThis PR has been re-verified and all required checks are passing (Dependencies Check, license/cla). Remaining gate is maintainer approval (REVIEW_REQUIRED / Community PR Approvals).\n\nCould you please review and approve when you have a moment?

@mjbvz

Copy link
Copy Markdown
Contributor

This setting is used by a very small percentage of users and the linked original issue doesn't seem to mention it? Without more evidence this doesn't seem like the root cause

@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Host becomes unresponsive during synchronous subprocess wait instead of timing out cleanly

5 participants